package com.example.demo.mapper;

import com.example.demo.pojo.entity.OrderDetail;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface OrderDetailMapper {


    @Select("select * from order_detail where order_id=#{orderId}")
    List<OrderDetail> getByOrderId(Long orderId);

    void insertBatch(List<OrderDetail> orderDetailList);

    @Select("select sum(amount) from order_detail where category=#{category} and DATE (create_time) >=DATE_ADD(CURDATE(), INTERVAL 1-DAYOFMONTH(CURDATE()) DAY) and DATE (create_time) <LAST_DAY(CURDATE())")
    Double getByCategory(String category);
}
